<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%
	String path = request.getContextPath();
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script language="javascript" type="text/javascript" src="js/jquery-1.4.2.js"></script>
<script>

function do_submit(){
	if($("#account").val()==""){
		alert("请输入用户名！");
		return false;
	}else if($("#password").val()==""){
		alert("请输入密码！");
		return false;
	}
	
	var path = $("#path").val();
	$("#MyForm").attr("action",path+"/customermgt/init");
	$("#MyForm").attr("method","get");
	//alert("asdfasdfasdf:::::"+path+"/Login");
	$("#MyForm").submit();
}

function validate(){
	if($("#account").val()!=""){
		var url=$("#path").val()+"/customermgt/validate_ajax";
		var params={"account":$("#account").val()};
		//var retValue;
		$.ajax({   
			type:"POST",
			url:url,  
			data:params,
			dataType: "json",
			async:false,
			success:function(data){
				//alert(data);
				var temp = $("#d1").html();
				$("#d1").html(temp+data.responseText);
				$("#d1").attr("style","display:");
			}
		});
	}
}

function do_add(){
	//var temp = $("#d2").html();
	var trtd = "<tr><th width=\"30%\">联系人：</th><td width=\"30%\"><input type=\"text\" id=\"contact\" name=\"contact\" value=\"\"/></td><td width=\"40%\"></td></tr>";
	$("#d2").append(trtd);
}

</script>
</head>
<body>
<form name="MyForm" id="MyForm">
	<input type="hidden" id="path" name="path" value="<%=path%>"/>
	<table id="T1" width="30%" border="0" cellpadding="0" cellspacing="0" align="center">
		<tr>
			<th width="30%">
				用户名：
			</th>
			<td width="30%">
				<input type="text" id="account" name="account" value="" onblur="validate()"/>
			</td>
			<td width="40%">
				<div id="d1" style="display:none"></div>
			</td>
		</tr>
		<tr>
			<th width="30%">
				密码：
			</th>
			<td width="30%">
				<input type="password" id="password" name="password" value=""/>
			</td>
			<td width="40%">
			</td>
		</tr>
	</table>
	<table id="T3" width="30%" border="0" cellpadding="0" cellspacing="0" align="center">
		<tbody id="d2"></tbody>
	</table>
	<table id="T2" width="30%" border="0" cellpadding="0" cellspacing="0" align="center">
		<tr>
			<td width="50%" align="center">
				<input type="button" name="BSubmit" value="提交" onclick="do_submit()"/>
			</td>
			<td width="50%" align="center">
				<input type="button" name="BAdd" value="增加" onclick="do_add()"/>
			</td>
		</tr>
	</table>
</form>
</body>
</html>